package net.chowda.castcluster.util;

import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;

import java.net.URL;

/**
 * we use this to get log4j Loggers mostly just so we can force the XML config we want.
 */
public class LogUtil {
	static {
		URL configFile = Thread.currentThread().getContextClassLoader().getResource("log4j.xml");
		if (configFile == null) {
			throw new IllegalArgumentException("couldn't find log4j.xml in the classpath... this is fatal.");
		} else {
			System.out.println("Initializing log4j from config file :" + configFile);
			DOMConfigurator.configure(configFile);
		}
	}

	public static Logger getLogger(Class clazz) {
		return Logger.getLogger(clazz);
	}
	
	public static Logger getLogger(String string) {
		return Logger.getLogger(string);
	}

	private LogUtil() {}
}
